/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 - 2008 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.projects.csv.bean.impl;

import java.util.Date;

import com.genia.toolbox.projects.csv.bean.CsvVersion;
import com.genia.toolbox.projects.csv.bean.MutableCsvVersion;

/**
 * bean that represents the csv file version.
 */
public class CsvVersionImpl
    implements MutableCsvVersion, Comparable<CsvVersion>
{

  /**
   * the version number.
   */
  private Integer versionNumber;

  /**
   * the date of the version.
   */
  private Date versionDate;



  /**
   * getter for the versionDate property.
   * 
   * @return the versionDate
   */
  public Date getVersionDate()
  {
    return versionDate;
  }



  /**
   * setter for the versionDate property.
   * 
   * @param versionDate
   *          the versionDate to set
   */
  public void setVersionDate(Date versionDate)
  {
    this.versionDate = versionDate;
  }



  /**
   * getter for the versionNumber property.
   * 
   * @return the versionNumber
   */
  public Integer getVersionNumber()
  {
    return versionNumber;
  }



  /**
   * setter for the versionNumber property.
   * 
   * @param versionNumber
   *          the versionNumber to set
   */
  public void setVersionNumber(Integer versionNumber)
  {
    this.versionNumber = versionNumber;
  }



  /**
   * compare two CsvVersion objects.
   * 
   * @param obj
   *          the other CsvVersion object
   * @return negative integer, zero, or a positive integer as this object is
   *         less than, equal to, or greater than the specified object
   */
  public int compareTo(CsvVersion obj)
  {
    int res = this.getVersionNumber().compareTo(obj.getVersionNumber());
    if (res != 0) {
      return res;
    }
    return this.getVersionDate().compareTo(obj.getVersionDate());
  }



  /**
   * check if two CsvVersion object is equal.
   * 
   * @param obj
   *          the other CsvVersion object
   * @return true if equal, otherwise false
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    CsvVersionImpl other = (CsvVersionImpl) obj;
    return (this.getVersionNumber().equals(other.getVersionNumber()) & (this.getVersionDate().equals(other.getVersionDate())));
  }



  /**
   * Returns a hash code value for the object. This method is supported for the
   * benefit of hashtables such as those provided by
   * <code>java.util.Hashtable</code>.
   * 
   * @return the hashCode
   * @see java.lang.Object#hashCode()
   */
  @Override
  public int hashCode()
  {
    return this.versionNumber.hashCode();
  }

}
